package cn.u313;
import io.github.kloping.qqbot.Starter;
import io.github.kloping.qqbot.api.Intents;
import io.github.kloping.qqbot.api.message.MessageChannelReceiveEvent;
import io.github.kloping.qqbot.api.v2.GroupMessageEvent;
import io.github.kloping.qqbot.entities.ex.Image;
import io.github.kloping.qqbot.entities.ex.MessageAsyncBuilder;
import io.github.kloping.qqbot.entities.qqpd.data.Emoji;
import io.github.kloping.qqbot.impl.ListenerHost;
/**
 * @ProjectName: bot_220624
 * @Package: cn.u313
 * @ClassName: DemoApp
 * @Author: 柳苏言
 * @Description: test
 * @Date: 2023/12/17 18:32
 * @Version: 1.0
 */
public class DemoApp {
    /**
     *
     "appId": "102072332",
     "token": "SlV68XQJrOcyEPa0IzWjd8B0khXrq0Pz",
     "secret": "JRK1TikY83kCPN6b"
     * @param args
     */
    public static void main(String[] args) {
        Starter starter = new Starter("102072332", "SlV68XQJrOcyEPa0IzWjd8B0khXrq0Pz", "JRK1TikY83kCPN6b");
        //===================================公域推荐订阅===============↓群聊/好友 事件订阅
        starter.getConfig().setCode(Intents.PUBLIC_INTENTS.and(Intents.GROUP_INTENTS));
        starter.run();
        starter.registerListenerHost(new ListenerHost() {

            @EventReceiver
            public void onMessage(MessageChannelReceiveEvent event) {
//                MessageAsyncBuilder builder = new MessageAsyncBuilder();
//                builder.append("测试发图!");
//                builder.append(new Image("http://kloping.top/icon.jpg"));
//                builder.append(Emoji.K歌);
//                event.send(builder.build());
                System.out.println("onMessage");
            }

            /**
             * 因为是公域 所以仅当bot被at时才能触发事件
             * @param event
             */
            @EventReceiver
            public void onMessage(GroupMessageEvent event) {
                System.out.println("GroupMessageEvent");
//                MessageAsyncBuilder builder = new MessageAsyncBuilder();
//                builder.append("测试发图!");
//                //目前仅支持 以url发送图片 https://bot.q.qq.com/wiki/develop/api-231017/server-inter/message/send-receive/rich-text-media.html#%E5%8F%91%E9%80%81%E5%88%B0%E7%BE%A4%E8%81%8A
//                builder.append(new Image("http://kloping.top/icon.jpg"));
//                builder.append(Emoji.K歌);
//                event.sendMessage(builder.build());
            }
        });

    }
}
